Skip to content

fix(gemini): sanitize schema keywords in function responses to prevent 400 - #3411

Open
AhooraZen wants to merge 1 commit into
decolua:masterfrom
AhooraZen:fix-gemini-tool-response-schema-refs
Open

fix(gemini): sanitize schema keywords in function responses to prevent 400#3411
AhooraZen wants to merge 1 commit into
decolua:masterfrom
AhooraZen:fix-gemini-tool-response-schema-refs

Conversation

@AhooraZen

Copy link
Copy Markdown

Problem

When tool output (e.g. from webfetch or JSON schema files) contains keys like $ref, $defs, #, or /, tryParseJSON parses them into the functionResponse.response object.

Google Gemini / Antigravity protobuf parser treats these keys as schema references rather than payload data, failing with:

{"error":{"code":400,"message":"The referenced name `#/$defs/Config` in function_response.response does not match to a display_name in the function_response.parts.","status":"INVALID_ARGUMENT"}}

Solution

  • Added sanitizeFunctionResponseResult in open-sse/translator/formats/gemini.js to recursively sanitize forbidden schema characters ($, #, /, definitions) in tool result objects before constructing functionResponse.
  • Added unit test in scripts/test-gemini-tool-response-sanitization.mjs.

afandiaziz added a commit to afandiaziz/9router that referenced this pull request Aug 20, 2026
afandiaziz added a commit to afandiaziz/9router that referenced this pull request Aug 20, 2026
…/security/providers

Verified via trial-merge + per-PR tests (84 pass/0 fail), OAuth baseline
identical, providers baseline additive-only (+reasonix/ovh/joycode/openmodel).

PRs: decolua#3411 decolua#3370 decolua#3369 decolua#3368 decolua#3393 decolua#3366 decolua#3395 decolua#3382 decolua#3359 decolua#3408 decolua#3357
     decolua#3379 decolua#3380 decolua#3381 decolua#3396 decolua#3338

Co-Authored-By: Claude <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants